<template>
	<view class="padding-30">
		<view class="bg-fff flex-between padding-30 border-radius20 margin-bottom20" 
		v-for="(item,index) in list" :key="index">
			<view class="">
				<view class="fontSize-15 color-000 margin-bottom20">{{item.name}} {{item.status}}</view>
				<view class="fontSize-13 color-999">{{item.createtime}}</view>
			</view>
			<view class="fontSize-18 color-000">{{item.money}}</view>
		</view>
	</view>
</template>

<script>
	export default {
		data(){
			return{
				page: 1,
				limit: 10,
				list: [],
				isLastPage: false,
				loading: false,
			}
		},
		onShow() {
			if (uni.getStorageSync('token')) {
				this.page = 1
				this.limit = 10
				this.list = []
				this.getExtractList()
			}
		},
		// 刷新 上拉刷新
		onPullDownRefresh() {
			this.page = 1
			this.isLastPage = false
			this.list = []
			this.getExtractList().finally(() => {
				// 停止当前页面下拉刷新
				uni.stopPullDownRefresh();
			});
		},
		// 加载下一页 下拉加载
		onReachBottom() {
			if (this.list.length >= this.page * this.limit) {
				this.isLastPage = false;
				this.page += 1;
				this.getExtractList()
			} else {
				this.isLastPage = true
			}
		},
		methods:{
			// 获取积分明细列表
			async getExtractList(){
				let res = await this.$http.post(this.$api.extract_list,{page:this.page,limit:this.limit},{token:true})
				if (res.code == 1) {
					this.list = [...this.list, ...res.data]
				}
			}
		}
	}
</script>

<style lang="scss" scoped>
	
</style>